return (calledContractPayable.send(2 ether));
}
}
2.5.18 Error Handling
Error handling refers to the routines in a program that respond to the
abnormal input or conditions. Similar to the high level languages
such as Java, Scala, JavaScript etc., Solidity has a feature to revert
the state changes in case of any issues occurring while running the
code. There are quite a few different ways to handle the exceptions.
The following is the list:
require
revert
assert
try/catch
2.5.18.1 Require
Require might be useful for validating the inputs to a function or the
output from an external contract or for running to check the
parameters before running a condition.
Refer to the following code:
// SPDX-License-Identifier: SOME IDENTIFIER
pragma solidity ^0.8.10;
contract RequireFunctionTest {
uint someValue;
function testRequireWithoutString(uint localValue) public
{
require(localValue >= 100);
someValue = localValue;
}
function testRequireWithString(uint localValue) public {